import request from '../utils/request';

/**
 * 修改密码
 * @param params
 * @returns {AxiosPromise}
 */
export const updatepwd = params => {
    return request({
        url: '/api/user/update',
        method: 'put',
        data: params,
        headers:{
            'Content-Type':'application/json'
        },
    });
};

/**
 * 发布公告
 * @param params
 * @returns {AxiosPromise}
 */
export const updateAnno = params => {
    return request({
        url: '/api/announcement/addAnno',
        method: 'POST',
        data: params,
        headers:{
            'Content-Type':'application/json'
        },
    });
};

/**
 * 获取公告列表(增加分页)
 * @param params
 * @returns {AxiosPromise}
 */
export const getAnnoList = params => {
    return request({
        url: '/api/announcement/queryByTime',
        method: 'get',
        params
    });
};

/**
 * 根据id修改公告
 */
export const updateAnnoById = params => {
    return request({
        url: '/api/announcement/updateAnno',
        method: 'put',
        data: params,
        headers:{
            'Content-Type':'application/json'
        },
    });
};

/**
 * 删除公告
 */
export const delAnno = params => {
    return request({
        url: '/api/announcement/delAnno?id='+params.annoid,
        method: 'delete'
    });
};

/**
 * 批量删除公告
 */
export const deleteByIds = params => {
    return request({
        url: "/api/announcement/delByIds",
        method: "post",
        data: JSON.stringify(params),
        headers:{
            'Content-Type':'application/json'
        },
    });
};

/**
 * 根据时间段查询进行分页
 */
export const getAnnoListByDate = params => {
    return request({
        url: '/api/announcement/queryByTime',
        method: 'get',
        params
    });
};

/**
 * 查询个人信息
 */
export const getOne = params => {
    return request({
        url: '/api/user/queryPersonalInfo?username='+params,
        method: 'get'
    });
};

/**
 * 修改个人信息
 */
export const updateInfo = params => {
    return request({
        url: '/api/user/update',
        method: 'put',
        data: params,
        headers:{
            'Content-Type':'application/json'
        },
    });
};

/**
 * 添加课程
 */
export const addCourse = params => {
    return request({
        url: '/api/course/addCourse',
        method: 'POST',
        data: params,
        headers:{
            'Content-Type':'application/json'
        },
    });
};

/**
 * 视频列表
 */
export const getMvList = params => {
    return request({
        url: '/api/mv/queryMvByName',
        method: 'get',
        params
    });
};

/**
 * 修改视频
 */
export const updateMvById = params => {
    return request({
        url: '/api/mv/updateMv',
        method: 'post',
        data: params,
        headers:{
            'Content-Type':'application/json'
        },
    });
};
/**
 * 删除视频
 *delMv
 */
export const delMv = params => {
    return request({
        url: '/api/mv/del?id='+params.mvid,
        method: 'delete'
    });
};

/**
 * 批量删除视频
 * delByIds
 */
export const delByIds = params => {
    return request({
        url: "/api/mv/delMore",
        method: "post",
        data: JSON.stringify(params),
        headers:{
            'Content-Type':'application/json'
        },
    });
};

/**
 * getReceiverList 获取所有人员
 */
export const getReceiverList = params => {
    return request({
        url: '/api/user/queryOthers?id='+params.userid,
        method: 'get',
    });
};

/**
 * addMsg 新增留言
 */
export const addMsg = params => {
    return request({
        url: '/api/msg/addmsg',
        method: 'post',
        data: params,
        headers:{
            'Content-Type':'application/json'
        },
    });
};

/**
 * 获取留言的列表 getMsgList
 */
export const getMsgList = params => {
    return request({
        url: '/api/msg/querymsg',
        method: 'get',
        params
    });
};
/**
 * 删除留言记录 delMsg
 */
export const delMsg = params => {
    return request({
        url: '/api/msg/delMsg?id='+params.msgid,
        method: 'delete'
    });
};

/**
 * 批量删除留言记录 delMsgByIds
 */
export const delMsgByIds = params => {
    return request({
        url: "/api/msg/delMore",
        method: "post",
        data: JSON.stringify(params),
        headers:{
            'Content-Type':'application/json'
        },
    });
};

/**
 * getUnreadList
 * 获取未读留言
 */
export const getUnreadList = params => {
    return request({
        url: '/api/msg/getUnreadList?id='+params.userid,
        method: 'get',
    });
};

/**
 * getReadList
 * 获取已读留言
 */
export const getReadList = params => {
    return request({
        url: '/api/msg/getReadList?id='+params.userid,
        method: 'get',
    });
};

/**
 * getRecycleList
 * 放入回收站的留言
 */
export const getRecycleList = params => {
    return request({
        url: '/api/msg/getRecycleList?id='+params.userid,
        method: 'get',
    });
};

/**
 * markRead 标记已读
 */
export const markRead = params => {
    return request({
        url: '/api/msg/markRead?flag=1&id='+params.msgid,
        method: 'put'
    });
};

/**
 * 标记为放入回收站
 */
export const markCycle = params => {
    return request({
        url: '/api/msg/markRead?flag=2&id='+params.msgid,
        method: 'put'
    });
};

/**
 * 标记为还原
 */
export const reduction = params => {
    return request({
        url: '/api/msg/markRead?flag=3&id='+params.msgid,
        method: 'put'
    });
};

/**
 * 批量放入回收站cycleByIds
 */
export const cycleByIds = params => {
    return request({
        url: "/api/msg/cycleByIds",
        method: "post",
        data: JSON.stringify(params),
        headers:{
            'Content-Type':'application/json'
        },
    });
};



/**
 *readByIds 全部标记为已读
 */
export const readByIds = params => {
    return request({
        url: "/api/msg/readByIds",
        method: "post",
        data: JSON.stringify(params),
        headers:{
            'Content-Type':'application/json'
        },
    });
};

/**
 * 清空回收站deleByIds 全部删除（真删除）
 */
export const deleByIds = params => {
    return request({
        url: "/api/msg/deleByIds",
        method: "post",
        data: JSON.stringify(params),
        headers:{
            'Content-Type':'application/json'
        },
    });
};

/**
 * 获取所有课程getCourseList(分页)
 */
export const getCourseList = params => {
    return request({
        url: '/api/course/getCourseList',
        method: 'get',
        params
    });
};

/**
 * 添加用户
 */
export const addUser = params => {
    return request({
        url: '/api/user/addUser',
        method: 'post',
        data: params,
        headers:{
            'Content-Type':'application/json'
        },
    });
};

/**
 * 获取用户列表
 */
export const getUserList = params => {
    return request({
        url: '/api/user/getVipList',
        method: 'get',
        params
    });
};

/**
 *updateUserById 修改用户
 */
export const updateUserById = params => {
    return request({
        url: '/api/user/update',
        method: 'put',
        data: params,
        headers:{
            'Content-Type':'application/json'
        },
    });
};

/**
 * delUser 删除用户
 */
export const delUser = params => {
    return request({
        url: '/api/user/del?id='+params.userid,
        method: 'delete'
    });
};


/**
 * deleteUserByIds  批量删除用户
 */
export const deleteUserByIds = params => {
    return request({
        url: "/api/user/delByIds",
        method: "post",
        data: JSON.stringify(params),
        headers:{
            'Content-Type':'application/json'
        },
    });
};

/**
 * getTeaList
 * 获取教练列表
 */
export const getTeaList = params => {
    return request({
        url: '/api/user/getTeaList',
        method: 'get',
        params
    });
};

/**
 * getCourseMvList  获取课程下视频的列表
 */
export const getCourseMvList = params => {
    return request({
        url: '/api/mv/queryMvByCourseId',
        method: 'get',
        params
    });
};



/**
 * updateCourseById 通过课程id修改课程
 */
export const updateCourseById = params => {
    return request({
        url: '/api/course/updateCourseById',
        method: 'put',
        data: params,
        headers:{
            'Content-Type':'application/json'
        },
    });
};

/**
 *delCourse 删除课程
 */
export const delCourse = params => {
    return request({
        url: '/api/course/delCourse?id='+params.courseid,
        method: 'delete'
    });
};

/**
 * deleteCourseByIds 批量删除课程
 */
export const deleteCourseByIds = params => {
    return request({
        url: "/api/course/delByIds",
        method: "post",
        data: JSON.stringify(params),
        headers:{
            'Content-Type':'application/json'
        },
    });
};

/**
 * exportAllTeacher 导出所有教练名单
 */
export const exportAllTeacher = params => {
    return request({
        url: "/api/user/exportAllUser?type=2",
        method: "get",
        // params:params,
        // responseType:'blob'
    });
};

/**
 * getTeaCourseList 获取教师所带课程
 */
export const getTeaCourseList = params => {
    return request({
        url: '/api/course/getTeaCourseList',
        method: 'get',
        params
    });
};

/**
 * delCourseMv 删除关系表中的关系，并不是真的删除视频
 */
export const delCourseMv = params => {
    return request({
        url: '/api/courseMv/delCourseMv',
        method: 'delete',
        data: params,
        headers:{
            'Content-Type':'application/json'
        },
    });
};


/**
 *getAllCourse  获取所有课程
 */
export const getAllCourse = params => {
    return request({
        url: '/api/course/getAllCourse',
        method: 'get',
        params
    });
};

/**
 *getAllMv  获取所有视频
 */
export const getAllMv = params => {
    return request({
        url: '/api/mv/getAllMv',
        method: 'get',
        params
    });
};

/**
 *addMvToCourse 将视频添加到课程
 */
export const addMvToCourse = params => {
    return request({
        url: '/api/courseMv/add',
        method: 'post',
        data: params,
        headers:{
            'Content-Type':'application/json'
        },
    });
};


/**
 *获取套餐列表 getComboList
 */
export const getComboList = params => {
    return request({
        url: '/api/combo/queryAll',
        method: 'get',
        params
    });
};

/**
 * 办卡 makeCard
 */
export const makeCard = params => {
    return request({
        url: '/api/combo/makeCard?userid='+params.userid+'&comboid='+params.comboid+'&ucsid='+params.ucsid,
        method: 'get'
    });
};

/**
 * 申请卡 applyCard
 */
export const applyCard = params => {
    return request({
        url: '/api/combo/applyCard?userid='+params.userid+'&comboid='+params.comboid,
        method: 'get'
    });
};


/**
 * 根据用户id来查询 getMyCard
 */
export const getMyCard = params => {
    return request({
        url: '/api/card/getMyCard?id='+params.userid,
        method: 'get'
    });
};

/**
 * 获取购买套餐记录 getComboRecord
 */
export const getComboRecord = params => {
    return request({
        url: '/api/combo/getComboRecord',
        method: 'get',
        params
    });
};


/**
 * 充值
 * @param params
 * @returns {AxiosPromise}
 */
export const pay = params => {
    return request({
        url: '/api/payRecord/pay?userid='+params.userid+'&amount='+params.amount,
        method: 'get'
    });
};

/**
 * getPaymentList  获取充值记录
 */
export const getPaymentList = params => {
    return request({
        url: '/api/payRecord/getPaymentList',
        method: 'get',
        params
    });
};

/**
 * getPriceById  根据课程id获取单价
 */
export const getPriceById = params => {
    return request({
        url: '/api/coursePrice/getPriceById',
        method: 'get',
        params
    });
};



/**
 * buyCourseById  购买课程
 */
export const buyCourseById = params => {
    return request({
        url: '/api/coursePrice/buyCourseById',
        method: 'get',
        params
    });
};

/**
 * getMyCourseList 获取我的课程
 */
export const getMyCourseList = params => {
    return request({
        url: '/api/cardCourse/getMyCourseList',
        method: 'get',
        params
    });
};


/**
 * getCourseVipList 获取某一课程下的vip列表
 */
export const getCourseVipList = params => {
    return request({
        url: '/api/cardCourse/getCourseVipList',
        method: 'get',
        params
    });
};

/**
 * getAllTeacher 获取所有教练回显到为教练分配课程的界面
 */
export const getAllTeacher = params => {
    return request({
        url: '/api/user/getAllTeaList',
        method: 'get'
    });
};

/**
 * addCourseToTeacher  将记录添加到cardCourse中
 */
export const addCourseToTeacher = params => {
    return request({
        url: '/api/user/addCourseToTeacher',
        method: 'post',
        data: params,
        headers:{
            'Content-Type':'application/json'
        },
    });
};

/**
 * getPayList 获取充值记录
 */
export const getPayList = params => {
    return request({
        url: '/api/payRecord/getPayList',
        method: 'get',
        params
    });
};

/**
 * getCheckCardList 获取充值记录
 */
export const getCheckCardList = params => {
    return request({
        url: '/api/combo/getCheckCardList',
        method: 'get',
        params
    });
};

/**
 * ChangeStatus 审核充值信息
 */
export const ChangeStatus = params => {
    return request({
        url: '/api/payRecord/ChangeStatus?payno='+params.payno+'&payamount='+params.payamount+'&userid='+params.userid,
        method: 'get',
    });
};

/**
 * getNewAnno 获取最新的10条公告
 */
export const getNewAnno = params => {
    return request({
        url: '/api/announcement/getNewAnno',
        method: 'get'
    });
};

/**
 * getAllVipCardList 获取所有的Vip的卡并回显到界面上
 */
export const getAllVipCardList = params => {
    return request({
        url: '/api/user/getAllVipCardList',
        method: 'get',
        params
    });
};

/**
 * getMoneyByMonth  获取近五个月销售金额
 */
export const getMoneyByMonth = params => {
    return request({
        url: '/api/payRecord/getMoneyByMonth',
        method: 'get'
    });
};

/**
 * getTotalUser,getTotalCourse,getTotalCombo
 */
export const getTotalUser = params => {
    return request({
        url: '/api/user/getTotalUser',
        method: 'get'
    });
};

export const getTotalCourse = params => {
    return request({
        url: '/api/course/getTotalCourse',
        method: 'get'
    });
};

export const getTotalCombo = params => {
    return request({
        url: '/api/combo/getTotalCombo',
        method: 'get'
    });
};

/**
 * getComboCount 获取每一个套餐的销售额
 */
export const getComboCount = params => {
    return request({
        url: '/api/combo/getComboCount',
        method: 'get'
    });
};
